package controleur;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import model.FileManagement;
import view.PrincipalWindow;
import view.SearchForm;

public class MainControleur {

	/**
	 * @param args
	 */
	public static String filename = "addbook.csv";
	public static File outputFile;
	public static boolean exist;
	public static ArrayList<ArrayList<String>> data;
	public static HashMap<String, ArrayList<String>> dataHM;
	public static FileManagement file;
	public static PrincipalWindow fen;
	
	public static void main(String[] args) throws IOException {
//		// TODO Auto-generated method stub
		
		dataHM = new HashMap<String, ArrayList<String>>();
		

		file = new FileManagement();
		outputFile = new File(filename);
		System.out.println(outputFile.createNewFile());

		
		
		data = new ArrayList<ArrayList<String>>();
		Thread t = new Thread(){
            public void run() {
            	data = file.lectureFichier(filename);
            }
        };
        t.start();

        Thread t2 = new Thread(){
            public void run() {
            	 fen = new PrincipalWindow();
         		ActionVue action = new ActionVue(fen);
         		fen.getjButtonAdd().addActionListener(action);
        		fen.getjButtonEdit().addActionListener(action);
        		fen.getjButtonDelete().addActionListener(action);
        		fen.getjButtonDisplay().addActionListener(action);
        		fen.getjButtonSearch().addActionListener(action);
            }
        };
        t2.start();

		
		
		ArrayList<ArrayList<String>> data1 = new ArrayList<ArrayList<String>>();
		ArrayList<String> con = new ArrayList<String>();
		exist = outputFile.exists();
		
		
		/*if (exist == false){
		con.add("First Name");
		con.add("Last Name");
		con.add("Group");
		con.add("Address Home");
		con.add("Address Company");
		con.add("Home Phone");
		con.add("Mobile Phone");
		con.add("Professional Phone");
		con.add("Personal Email");
		con.add("Professional Email");
		con.add("Web Page");
		con.add("src\\contact.png");		
		data1.add(con);
		}
		
		System.out.println(con);
		System.out.println(data1);
		try {
			exist = outputFile.exists();
			for (int i =0; i<100000; i++)
				file.ecritureFichier(outputFile, data1, exist);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}*/
		
		
		
	}

}
